package xcmg.device.web.question;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import xcmg.device.infra.BasicController;
import xcmg.device.service.question.QuestionTrackService;
import xcmg.device.service.vo.question.QuestionTrackVO;
import yb.ecp.fast.infra.annotation.FastMappingInfo;
import yb.ecp.fast.infra.infra.ActionResult;
import yb.ecp.fast.infra.infra.SearchCommonVO;

@RestController
@RequestMapping("/questionTrack")
@Api("问题追踪")
public class QuestionTrackController extends BasicController {

	@Autowired
	private QuestionTrackService questionTrackService;
	
	@PostMapping(value = "/add")
    @ApiOperation(value = "新增")
    @FastMappingInfo(needLogin = true)
	public ActionResult<String> add(@RequestBody QuestionTrackVO questionTrackVO) throws Exception {
		return actionResult(questionTrackService.add(questionTrackVO, getUserId(), getUserName()));
	}
	
	@PostMapping(value = "/update")
    @ApiOperation(value = "更新")
    @FastMappingInfo(needLogin = true)
	public ActionResult<String> update(@RequestBody QuestionTrackVO questionTrackVO) {
		return actionResult(questionTrackService.update(questionTrackVO, getUserId(), getUserName()));
	}
	
	@GetMapping(value = "/item")
    @ApiOperation(value = "更新")
    @FastMappingInfo(needLogin = true)
	public ActionResult<QuestionTrackVO> item(String id) throws Exception {
		return actionValueResult(questionTrackService.item(id));
	}
	
	@PostMapping(value = "/pageList")
    @ApiOperation(value = "分页查询")
    @FastMappingInfo(needLogin = true)
	public ActionResult pageList(@RequestBody SearchCommonVO<QuestionTrackVO> condition) {
		return actionValueResult(questionTrackService.pageList(condition).getPageInfo());
	}
	
	@GetMapping(value = "/delete")
    @ApiOperation(value = "删除")
    @FastMappingInfo(needLogin = true)
	public ActionResult delete(String id) {
		return actionResult(questionTrackService.delete(id));
	}
	
	@PostMapping(value = "/batchDel")
    @ApiOperation(value = "批量删除")
    @FastMappingInfo(needLogin = true)
	public ActionResult batchDel(@RequestBody List<String> ids) {
		return actionResult(questionTrackService.batchDel(ids));
	}
}
